<template>
  <div class="app-container yzh-finance">
    <avue-form
      v-if="formData.id"
      :option="formOption"
      v-model="formData"
      ref="formRef"
    >
      <!-- <template #cyhscb-label="{ column }">
        <span class="leading-snug">{{ column.label }}</span>
      </template> -->
      <!-- <template #menu-form="{ size }">
        <el-button
          icon="Search"
          type="primary"
          :size="size"
          @click="handleSubmit"
          >提交</el-button
        >
        <el-button icon="Refresh" :size="size" @click="handleReset(form)"
          >重置</el-button
        >
      </template> -->
    </avue-form>
  </div>
</template>
<script setup name="Finance">
import { reactive, toRefs, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()
const { proxy } = getCurrentInstance()
const {
  ord_product_plate_type,
  ord_product_plate,
  yes_or_no,
  measurement_unit,
  credit_rating,
  quantity_accuracy,
  addition_method,
  device_type,
  warehouse_info,
  self_product,
  product_bussiness_plate,
  transaction_type
} = proxy.useDict(
  'ord_product_plate_type',
  'ord_product_plate',
  'yes_or_no',
  'measurement_unit',
  'credit_rating',
  'quantity_accuracy',
  'addition_method',
  'device_type',
  'warehouse_info',
  'self_product',
  'product_bussiness_plate',
  'transaction_type'
)

const props = defineProps({
  productData: {
    type: Object,
    require: true
  }
})
const data = reactive({
  formOption: {
    tabs: false,
    submitBtn: false,
    emptyBtn: false,
    disabled: true,
    labelWidth: '140',
    column: [
      {
        label: '销售价',
        // labelWidth: '0',
        prop: 'price',
        span: 12,
        placeholder: '销售价',
        append: '元',
        type: 'input',
        rules: [
          {
            required: true,
            message: '请输入销售价',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '默认仓库',
        // labelWidth: '0',
        span: 12,
        prop: 'defaultWarehouse',
        placeholder: '默认仓库',
        type: 'select',
        dicData: warehouse_info
      },
      {
        label: '采购参考价格',
        prop: 'purchaseReferencePrice',
        span: 12,
        placeholder: '采购参考价格',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入采购参考价格',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '默认货位',
        prop: 'defaultCargo',
        span: 12,
        placeholder: '默认货位',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入默认货位',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '内部交易参考价格',
        prop: 'tradingReferencePrice',
        span: 12,
        placeholder: '内部交易参考价格',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入内部交易参考价格',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '最低销售价格',
        // labelWidth: '0',
        prop: 'minSellingPrice',
        span: 12,
        placeholder: '最低销售价格',
        append: '元',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入最低销售价格',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '超订单入库比例',
        // labelWidth: '0',
        prop: 'excessOrderInventoryRatio',
        span: 12,
        placeholder: '超订单入库比例',
        // append: '元',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入超订单入库比例',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '最高销售价格',
        // labelWidth: '0',
        prop: 'maxSellingPrice',
        span: 12,
        placeholder: '最高销售价格',
        append: '元',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入最高销售价格',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '成本加成方式',
        // labelWidth: '0',
        span: 12,
        prop: 'additionType',
        placeholder: '成本加成方式',
        type: 'select',
        dicData: addition_method
      },
      {
        label: '成本加成比率',
        // labelWidth: '0',
        prop: 'additionRatio',
        span: 12,
        placeholder: '成本加成比率',
        // append: '元',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入成本加成比率',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '往来业务类型',
        // labelWidth: '0',
        span: 12,
        prop: 'transactionType',
        placeholder: '往来业务类型',
        type: 'select',
        dicData: transaction_type
      },
      {
        label: '成本加价',
        prop: 'markup',
        span: 12,
        placeholder: '成本加价',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入成本加价',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '安全库存',
        prop: 'safeInventory',
        span: 12,
        placeholder: '安全库存',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入安全库存',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '最低库存',
        prop: 'minInventory',
        span: 12,
        placeholder: '最低库存',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入最低库存',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '最高库存',
        prop: 'maxInventory',
        span: 12,
        placeholder: '最高库存',
        type: 'input',
        rules: [
          {
            required: false,
            message: '请输入最高库存',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '组装件',
        prop: 'assembly',
        type: 'radio',
        dicData: yes_or_no
      },
      {
        label: '是否允许零出库',
        prop: 'zeroExitControl',
        type: 'radio',
        dicData: yes_or_no
      }

      /* {
            label: '上传合同',
            prop: 'imgUrl',
            type: 'upload',
            span: 12,
            fileText: '上传合同',
            propsHttp: {
              url: 'url',
              name: 'name',
              res: 'data'
            },
            action: action
          }, */
    ]
  },
  formData: {}
})
let { formOption, formData } = toRefs(data)

function init() {
  formData.value = props.productData
}
init()
</script>
<style lang="scss" scoped></style>
